import re
import requests

url = 'http://www.weather.com.cn/weather/101280601.shtml'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'
}

resp = requests.get(url, headers=headers)
resp.encoding = 'utf=8'

pattern = r'<li>\s*<a href=".*?">\s*<span class="name">(\w+)</span>\s*<span class="weather">(\w+)</span>\s*<span class="wd">([0-9\/]+℃)</span>\s*<span class="zs">(\w+)</span>\s*</a>\s*</li>'
matches = re.findall(pattern, resp.text)

for v in matches:
    print(v, end='\n')

input()

